<?php

namespace app\admin\model;

use think\Db;
use think\Model;

class Classification extends Model
{
    protected $table = "auth_classification";
    public function index()
    {
        $list = Db::table($this->table)->paginate(2, false, ['query' => request()->param()]);

        return $list;
    }
    public function ClassificationAdd($data){
        Db::startTrans();
        $return  = false;
        try {
            $res = Db::table($this->table)->insertGetId($data);
            Db::commit();
            if ($res){
                $return = true;
            }
        }catch (\Exception $e){
            Db::rollback();
        }
        return $return;
    }
    public function ClassificationEdit($id,$data){
        Db::startTrans();
        $return  = false;
        try {
            $res = Db::table($this->table)->where(["id"=>$id])->update($data);
            Db::commit();
            if ($res){
                $return = true;
            }
        }catch (\Exception $e){
            Db::rollback();
        }
        return $return;
    }
}
